package com.example.demo.common;

/**
 * 错误码枚举
 */
public enum ErrorCode {
    
    SUCCESS(200, "操作成功"),
    PARAMS_ERROR(40000, "请求参数错误"),
    NOT_LOGIN_ERROR(40100, "未登录"),
    NO_AUTH_ERROR(40101, "无权限"),
    NOT_FOUND_ERROR(40400, "请求数据不存在"),
    FORBIDDEN_ERROR(40300, "禁止访问"),
    SYSTEM_ERROR(50000, "系统内部异常"),
    OPERATION_ERROR(50001, "操作失败"),

    // 用户相关错误码
    USERNAME_EXIST(41000, "用户名已存在"),
    USER_NOT_EXIST(41001, "用户不存在"),
    USER_ACCOUNT_FORBIDDEN(41002, "账号已被禁用"),

    PASSWORD_ERROR(40102, "密码错误"),
    PASSWORD_EMPTY(40103, "密码不能为空"),
    PASSWORD_LENGTH_ERROR(40104, "密码长度必须在6-20位之间"),
    PASSWORD_FORMAT_ERROR(40105, "密码必须包含字母和数字"),
    OLD_PASSWORD_ERROR(40106, "原密码错误"),
    TWO_PASSWORD_NOT_MATCH(40107, "两次输入的密码不一致"),
    ACCOUNT_NOT_EXIST(40108, "账号不存在"),
    ACCOUNT_ALREADY_EXIST(40109, "账号已存在"), 
    ACCOUNT_LOCKED(40110, "账号已被锁定"),
    ACCOUNT_DISABLED(40111, "账号已被禁用"),
    ACCOUNT_EXPIRED(40112, "账号已过期"),
    ACCOUNT_FORMAT_ERROR(40113, "账号格式错误"),
    ACCOUNT_EMPTY(40114, "账号不能为空"),
    ACCOUNT_LENGTH_ERROR(40115, "账号长度必须在4-20位之间"),

    // 管理员相关错误码 41000-41999
    ADMIN_NOT_EXIST(41000, "管理员不存在"),
    ADMIN_PASSWORD_ERROR(41001, "管理员密码错误"),
    ADMIN_DISABLED(41002, "管理员账号已被禁用"),
    ADMIN_NOT_PERMISSION(41003, "非管理员用户，无权访问"),
    ADMIN_TOKEN_INVALID(41004, "管理员token无效"),
    ADMIN_TOKEN_EXPIRED(41005, "管理员token已过期");
   

    /**
     * 状态码
     */
    private final int code;

    /**
     * 信息
     */
    private final String message;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
} 